<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>核心事件</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.7 -->
    <!--link导入外部的css，js样式，如果导入的资源和本页面在同一个文件夹下，直接文件名即可-->
    <link rel="stylesheet" th:href="@{/asserts/bower_components/bootstrap/dist/css/bootstrap.min.css}">
    <!-- jQuery 3 -->
    <script th:src="@{/asserts/bower_components/jquery/dist/jquery.min.js}"></script>
    <!-- Bootstrap 3.3.7 -->
    <script th:src="@{/asserts/bower_components/bootstrap/dist/js/bootstrap.min.js}"></script>
    <!-- Font Awesome -->
    <link rel="stylesheet" th:href="@{/asserts/bower_components/font-awesome/css/font-awesome.min.css}">
    <!-- Ionicons -->
    <link rel="stylesheet" th:href="@{/asserts/bower_components/Ionicons/css/ionicons.min.css}">
    <!-- DataTables -->
    <link rel="stylesheet" th:href="@{/asserts/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css}">
    <!-- Theme style -->
    <link rel="stylesheet" th:href="@{/asserts/dist/css/AdminLTE.min.css}">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" th:href="@{/asserts/dist/css/skins/_all-skins.min.css}">
    <script th:src="@{/asserts/Apolar_sh/lib/layer/2.4/layer.js}"></script>

    <!-- Google Font -->
    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
    <style type="text/css">
        .search {
            margin-top: 40px;
            margin-left: 40px;
            position: relative;
        }

        td {
            text-align: center;
        }
        #home {
            display: block;
            position: absolute;
            right: 10px;
            top: 8px;
            z-index: 9999;
            font-size: 30px;
        }

        #refresh {
            display: block;
            position: absolute;
            right: 46px;
            top: 10px;
            z-index: 9999;
            font-size: 26px;
        }
    </style>

</head>
<body>
<span>
    <a id="refresh" class="fa fa-refresh"  href="javascript:location.reload()"></a>
    <a id="home" class="fa fa-home" th:href="@{/campus/infoFindAll}"></a>
</span>

<div class="wrapper">
    <!-- Content Wrapper. Contains page content -->
    <!-- Content Header (Page header) -->
    <!-- Main content -->
    <section class="content-header">
        <h4>
            <i class="fa fa-navicon"></i> 核心事件
        </h4>

    </section>
    <div class="search" style="margin-top: 0px;">

        <div class="row">
            <div class="col-xs-2">
                <h4 th:text="|院校名称:${campus.campusName}|">院校名称：清华大学</h4>
            </div>
            <div class="col-xs-2">
                <a class="btn btn-info" th:if="${info == null}"
                   th:href="@{/coreEvent/saveUI(campusId=${campus.campusId},RcurrentPage=${pageBean.pageNum},RpageSize=${pageBean.pageSize})}">
                    <i class="fa fa-plus"></i> 添加核心事件
                </a>
                <a class="btn btn-info" th:if="${info != null}"
                   th:href="@{/coreEvent/saveUI(campusId=${campus.campusId})}">
                    <i class="fa fa-plus"></i> 添加核心事件
                </a>
            </div>
            <div class="col-xs-2" th:if="${info != null}">
                <a class="btn btn-info" th:if="${session.user.authority == 1}"
                   th:href="@{/campus/infoFindAll(currentPage=${RcurrentPage},pageSize=${RpageSize})}">
                    <i class="fa fa-backward"></i> 返回
                </a>
                <a class="btn btn-info" th:if="${session.user.authority != 1}"
                   th:href="@{/campus/search(personname=${session.user.personname},currentPage=${RcurrentPage},pageSize=${RpageSize})}">
                    <i class="fa fa-backward"></i> 返回
                </a>
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
    </div>

    <!-- /.content -->
</div>

<div class="wrapper">
    <!-- Content Wrapper. Contains page content -->
    <!-- Content Header (Page header) -->
    <input type="text" hidden th:value="${info}" id="info">
    <div th:if="${info != null}" style="width: 270px;margin: auto">
        <p style="color: #ff0000;font-size: 30px;font-weight: bold">[[${info}]]</p>
    </div>

    <!-- Main content -->
    <section class="content" th:if="${info == null}">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <!-- /.box-header 部门列表的显示  table  表格  th/td单元个   th字体加粗，行标题-->
                    <div class="box-body">
                        <form th:action="@{/coreEvent/deleteGAll(campusId=${campus.campusId},RcurrentPage=${RcurrentPage},RpageSize=${RpageSize})}"
                              method="post">
                            <table id="example1" class="table table-bordered table-striped">
                                <tbody>
                                <tr>
                                    <td th:if="${session.user.authority != 3}">选择</td>
                                    <td>核心事件</td>
                                    <td th:if="${session.user.authority != 3}">操作</td>
                                </tr>
                                <tr th:each="groupId:${pageBean.list}">
                                    <td th:if="${session.user.authority != 3}">
                                        <input type="checkbox" name="Gids" class="checks"
                                               th:value="${groupId}"/>
                                    </td>
                                    <td>
                                        <a class="btn btn-info"
                                           th:href="@{/coreEvent/findByGid(Gid=${groupId},campusId=${campus.campusId},RcurrentPage=${pageBean.pageNum},RpageSize=${pageBean.pageSize})}">
                                            <i class="fa fa-reorder"></i> 核心事件
                                        </a>
                                    </td>
                                    <td  th:if="${session.user.authority != 3}">
                                        <a class="btn btn-danger" th:onclick="deleteByGid([[${groupId}]])"
                                          >
                                            <i class="fa fa-trash"></i> 删除
                                        </a>
                                    </td>
                                </tr>
                                <tr>
                                    <td th:if="${session.user.authority != 3}">
                                        <label><input type="checkbox" name="" id="all" value=""/>&nbsp;&nbsp;全选</label>

                                    </td>
                                    <td colspan="13" style="text-align:left;padding-left:20px;">
                                        <button th:if="${session.user.authority != 3}" class="btn btn-danger"
                                                onclick="return confirm('确认要删除？')" type="submit">
                                            <i class="fa fa-trash"></i> 删除
                                        </button>&nbsp;&nbsp;
                                        <a class="btn btn-info"
                                           th:href="@{/campus/infoFindAll(currentPage=${RcurrentPage},pageSize=${RpageSize})}">
                                            <i class="fa fa-backward"></i> 返回
                                        </a>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </form>
                        <!-- 分页 -->
                        <nav aria-label="Page navigation">
                            <ul class="pagination">
                                <li>
                                    <a th:if="${pageBean.pageNum != 1 }"
                                       th:href="@{/coreEvent/findGroup(currentPage=1,campusId=${campus.campusId})}">首页</a>
                                </li>
                                <li>
                                    <a th:if="${pageBean.pageNum==1 }"
                                       href="javascript:void(0)">首页</a>
                                </li>

                                <li th:if="${pageBean.pageNum!=1 }">
                                    <a th:href="@{/coreEvent/findGroup(currentPage=${pageBean.pageNum-1},campusId=${campus.campusId})}"
                                       aria-label="Previous">
                                        <span aria-hidden="true">&laquo;</span>
                                    </a>
                                </li>
                                <li class="disabled" th:if="${pageBean.pageNum==1 }">
                                    <a href="javascript:void(0)" aria-label="Previous">
                                        <span aria-hidden="true">&laquo;</span>
                                    </a>
                                </li>

                                <li th:classappend="${pageBean.pageNum==pageIndex}?'active':''"
                                    th:each="pageIndex:${pageValue}">
                                    <a
                                            th:if="${pageBean.pageNum==pageIndex}"
                                            th:text="${pageIndex}"></a>
                                    <a th:if="${pageIndex==-1}" style="cursor: default;opacity: 0.6;">
                                        ...
                                    </a>
                                    <a th:if="${pageBean.pageNum!=pageIndex&&pageIndex!=-1}"
                                       th:href="@{/coreEvent/findGroup(currentPage=${pageIndex},campusId=${campus.campusId})}"
                                       th:text="${pageIndex}"></a>
                                </li>

                                <li class="disabled" th:if="${pageBean.pageNum==pageBean.pages }">
                                    <a href="javascript:void(0)" aria-label="Next">
                                        <span aria-hidden="true">&raquo;</span>
                                    </a>
                                </li>
                                <li th:if="${pageBean.pageNum!=pageBean.pages }">
                                    <a th:href="@{/coreEvent/findGroup(currentPage=${pageBean.pageNum+1},campusId=${campus.campusId})}"
                                       aria-label="Next"> <span aria-hidden="true">&raquo;</span>
                                    </a>
                                </li>

                                <li>
                                    <a th:if="${pageBean.pageNum!=pageBean.pages }"
                                       th:href="@{/coreEvent/findGroup(currentPage=${pageBean.pages},campusId=${campus.campusId})}">末页</a>
                                </li>
                                <li>
                                    <a th:if="${pageBean.pageNum==pageBean.pages }"
                                       href="javascript:void(0)">末页</a>
                                </li>

                            </ul>
                        </nav>
                    </div>
                    <input id="currentPage" th:value="${pageBean.pageNum}" hidden>
                    <input id="currentPageSize" th:value="${pageBean.size}" hidden>
                    <input id="lastPage" th:value="${pageBean.pages}" hidden>
                    <input id="campusId" th:value="${campus.campusId}" hidden>
                    <!-- /.box-body -->
                </div>
                <!-- /.box -->
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
    </section>
    <!-- /.content -->
</div>

<!-- ./wrapper -->


<!-- DataTables -->
<script th:src="@{/asserts/bower_components/datatables.net/js/jquery.dataTables.min.js}"></script>
<script th:src="@{/asserts/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js}"></script>
<!-- SlimScroll -->
<script th:src="@{/asserts/bower_components/jquery-slimscroll/jquery.slimscroll.min.js}"></script>
<!-- FastClick -->
<script th:src="@{/asserts/bower_components/fastclick/lib/fastclick.js}"></script>
<!-- AdminLTE App -->
<script th:src="@{/asserts/dist/js/adminlte.min.js}"></script>
<!-- AdminLTE for demo purposes -->
<script th:src="@{/asserts/dist/js/demo.js}"></script>
<!-- page script -->
<script>
    // window.onload = function () {
    //     var flag = $("#info").val();
    //     if (flag.length > 0) {
    //         location.href = "[[${#httpServletRequest.getContextPath()}]]/coreEvent/findGroup?campusId=[[${campus.campusId}]]";
    //     }
    // }

    $("#all").click(function () {
        if (this.checked) {
            $(".checks").prop("checked", true);
            $("#all").prop("value", "全不选");
        } else {
            $(".checks").prop("checked", false);
            $("#all").prop("value", "全选");
        }
    });

    function deleteByGid(Gid) {
        layer.confirm("确认删除？",
            {
                btn: ['确定', '取消'] //按钮
            },
            function () {
                var currentPageSize = $("#currentPageSize").val();
                var currentPage = $("#currentPage").val();
                var lastPage = $("#lastPage").val();
                var campusId = $("#campusId").val();
                $.ajax({
                    url: '[[${#httpServletRequest.getContextPath()}]]/coreEvent/deleteByGid?currentPageSize=' + currentPageSize + '&currentPage=' + currentPage + '&lastPage=' + lastPage,
                    data: {
                        'Gid': Gid
                    },
                    success: function (result) {
                        console.log(result);
                        if (result == '1') {
                            layer.msg('删除成功！', {icon: 1, time: 1000});
                            location.reload();
                        } else if (result == '0') {
                            layer.msg('删除成功！', {icon: 1, time: 1000});
                            location.replace("[[${#httpServletRequest.getContextPath()}]]/coreEvent/findGroup?campusId=" + campusId + "&currentPage=" + (currentPage - 1));
                        }
                        else {
                            layer.msg('删除失败！', {icon: 0, time: 1000});
                        }

                    }
                })
            },
            function () {
                layer.msg('已取消！', {icon: 0, time: 500});
                return false;
            }
        );
    };
</script>
</body>
</html>